import time

from select import select
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

#获取浏览器并进入网页
d=webdriver.Edge()
d.get('http://127.0.0.1/ranzhi/www/')
time.sleep(2)
#输入并登录
d.find_element(By.ID,"account").send_keys("admin")
d.find_element(By.ID,"password").send_keys("123456")
d.find_element(By.ID,"submit").click()
time.sleep(2)
#点击添加客户
d.find_element(By.ID,"s-menu-1").click()
time.sleep(2)
#定位切换ifram
d.switch_to.frame(d.find_element(By.ID,"iframe-1"))
time.sleep(2)
#选择联系人
d.find_element(By.LINK_TEXT,"联系人").click()
d.find_element(By.LINK_TEXT,"添加联系人").click()
time.sleep(20)
#输入信息
#姓名
d.find_element(By.ID,"realname").send_keys("张三")
#客户
d.find_element(By.ID,"newCustomer").click()
d.find_element(By.ID,"name").send_keys("李四")
#性别
d.find_element(By.ID,"genderm").click()
#部门
d.find_element(By.ID,"dept").send_keys("销售部")
#职务
d.find_element(By.ID,"title").send_keys("销管")
#入职时间
d.find_element(By.ID,"join").send_keys("2025年9月2日")
#邮箱
d.find_element(By.ID,"email").send_keys("12345678@qq.com")
#手机
d.find_element(By.ID,"mobile").send_keys("123456789")
#电话
d.find_element(By.ID,"phone").send_keys("123454321")
#传真
d.find_element(By.ID,"fax").send_keys("12345")
#qq
d.find_element(By.ID,"qq").send_keys("1231231231")
#微信
d.find_element(By.ID,"weixin").send_keys("sdqoiqsnqdi")
#类型
a=d.find_element(By.ID,"type")
select = Select(a)
select.select_by_index(2)
#规模
b=d.find_element(By.ID,"size")
select1= Select(b)
select1.select_by_index(2)
#状态
c=d.find_element(By.ID,"status")
select2= Select(c)
select2.select_by_index(2)
#级别
f=d.find_element(By.ID,"level")
select3= Select(f)
select3.select_by_index(2)
#简介
d.find_element(By.ID,"desc").send_keys("这是公司简介")
#保存
d.find_element(By.ID,"submit").click()
time.sleep(5)
#退到最外层
d.switch_to.default_content()
#签退
d.find_element(By.CLASS_NAME,"sign.signout").click()
time.sleep(2)

